import { Message } from 'element-ui'

const MyMessage = option => {
  Message.closeAll()
  Message(option)
}

['success', 'warning', 'info', 'error'].forEach(type => {
  MyMessage[type] = options => {
    if (typeof options === 'string') {
      options = {
        message: options
      }
    }
    options.type = type
    Message.closeAll()
    return Message(options)
  }
})

export default MyMessage
